﻿@page
@{ Layout = "_Layout"; }

<el-container>
  <el-aside v-if="fileType != 'html'" width="100px">
    <el-tabs v-model="fileType" tab-position="left" style="height: 100%;" v-on:tab-click="reload">
      <el-tab-pane label="全部" name="All"></el-tab-pane>
      <el-tab-pane label="样式文件" name="css"></el-tab-pane>
      <el-tab-pane label="脚本文件" name="js"></el-tab-pane>
    </el-tabs>
  </el-aside>

  <el-container>
    <el-main>
      <el-form :inline="true" size="small">
        <el-form-item label="文件夹路径" prop="directoryPaths">
          <el-cascader
            v-model="directoryPaths"
            :options="directories"
            :props="{ multiple: true, checkStrictly: true }"
            filterable
            v-on:change="reload"
            placeholder="请选择文件夹路径"></el-cascader>
        </el-form-item>
        <el-form-item label="文件夹路径/文件名">
          <el-input
            v-model="keyword"
            v-on:change="reload"
            placeholder="请输入文件夹路径名称或文件名称"
          ></el-input>
        </el-form-item>
      </el-form>

      <el-table :data="files" style="width: 100%">
        <el-table-column label="资源文件">
          <template slot-scope="scope">
            <el-link
              :underline="false"
              v-on:click="btnEditClick(scope.row)"
              type="primary">
              {{ scope.row.directoryPath + '/' + scope.row.fileName }}
            </el-link>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="130">
          <template slot-scope="scope">
            <el-link
              :underline="false"
              :href="getPageUrl(scope.row.directoryPath + '/' + scope.row.fileName)"
              target="_blank"
              type="primary">
              查看
            </el-link>
            <el-link
              :underline="false"
              v-on:click="btnEditClick(scope.row)"
              type="primary">
              编辑
            </el-link>
            <el-link
              :underline="false"
              type="danger"
              v-on:click="btnDeleteClick(scope.row)">
              删除
            </el-link>
          </template>
        </el-table-column>
      </el-table>

      <div style="height: 10px"></div>
      <el-divider></el-divider>
      <div style="height: 10px"></div>

      <el-button v-if="fileType == 'html'" size="small" type="primary" v-on:click="btnAddClick('html')">
        新增包含文件
      </el-button>
      <el-button v-if="fileType == 'All' || fileType == 'css'" size="small" type="primary" v-on:click="btnAddClick('css')">
        新增样式文件
      </el-button>
      <el-button v-if="fileType == 'All' || fileType == 'js'" size="small" type="primary" v-on:click="btnAddClick('js')">
        新增脚本文件
      </el-button>
      <el-button size="small" type="primary" v-on:click="btnConfigClick">
        <i class="el-icon-setting"></i> 文件夹路径设置
      </el-button>
    </el-main>
  </el-container>
</el-container>

<el-drawer
  id="configForm"
  v-if="configForm"
  title="文件夹路径设置"
  ref="configPanel"
  :visible.sync="configPanel"
  destroy-on-close
  direction="rtl"
  size="50%">
  <div class="drawer__content">
    <el-form v-if="fileType == 'html'" ref="configForm" :model="configForm" label-width="150px" :rules="{
        includeDir: [
          { required: true, message: '请输入包含文件文件夹路径', trigger: 'blur' }
        ]
      }">
      <el-form-item label="包含文件文件夹路径" prop="includeDir">
        <el-input v-model="configForm.includeDir" placeholder="请输入包含文件文件夹路径"></el-input>
      </el-form-item>

      <el-divider></el-divider>
      <div class="drawer__footer">
        <el-button type="primary" v-on:click="btnConfigSubmitClick" size="small">确 定</el-button>
        <el-button size="small" v-on:click="btnConfigCancelClick">取 消</el-button>
      </div>
    </el-form>
    <el-form v-else ref="configForm" :model="configForm" label-width="150px" :rules="{
      cssDir: [
        { required: true, message: '请输入样式文件文件夹路径', trigger: 'blur' }
      ],
      jsDir: [
        { required: true, message: '请输入脚本文件文件夹路径', trigger: 'blur' }
      ]
    }">
    <el-form-item label="样式文件文件夹路径" prop="cssDir">
      <el-input v-model="configForm.cssDir" placeholder="请输入样式文件文件夹路径"></el-input>
    </el-form-item>
    <el-form-item label="脚本文件文件夹路径" prop="jsDir">
      <el-input v-model="configForm.jsDir" placeholder="请输入脚本文件文件夹路径"></el-input>
    </el-form-item>

    <el-divider></el-divider>
    <div class="drawer__footer">
      <el-button type="primary" v-on:click="btnConfigSubmitClick" size="small">确 定</el-button>
      <el-button size="small" v-on:click="btnConfigCancelClick">取 消</el-button>
    </div>
  </el-form>
  </div>
</el-drawer>

@section Scripts{
<script src="/sitefiles/assets/js/admin/cms/templatesAssets.js" type="text/javascript"></script>
}
